set echo off 
declare
	v_out_msg varchar2(4000);
    cursor simu_in_data 
	is 
        select  device_id, 1 data_type
           , device_sn +rownum   ||','||to_char(device_sn/level+1,'99.0')||',' ||
             (device_sn+rownum+2)||','||to_char(device_sn/level+3,'99.0')||',' ||
             (device_sn+rownum+4)||','||to_char(device_sn/level+5,'99.0')||',' ||
             to_char(device_sn*12345,'00000000')  data_str
              , to_char(sysdate + device_sn*17, 'yy.mm.dd.W') ip_addr
              , to_char(sysdate + device_sn*97, 'yyyy') ip_port  
        from device_list
        connect by level < 4
        union all 
        select device_id, 3 data_type
           ,  to_char(device_sn*9812345,'000,000,000')
            ||','||to_char(device_sn*735147 , '000,000,000') data_str
              , to_char(sysdate + device_sn*17, 'yy.mm.dd.W') ip_addr
              , to_char(sysdate + device_sn*97, 'yyyy') ip_port  
        from device_list
        connect by level < 3
        union all 
        select device_id, 4 data_type
           ,  to_char(device_sn*27.1231+sysdate,'YYYY,Month,DDD,hh24,mi,ss')
             data_str
              , to_char(sysdate + device_sn*17, 'yy.mm.dd.W') ip_addr
              , to_char(sysdate + device_sn*97, 'yyyy') ip_port  
        from device_list
        connect by level < 3
        union all 
        select device_id, 5 data_type
           ,  to_char(device_sn*2.97+sysdate,'YYYY,Month,DDD,hh24,ss')
             data_str
              , to_char(sysdate + device_sn*17, 'yy.mm.dd.W') ip_addr
              , to_char(sysdate + device_sn*97, 'yyyy') ip_port  
        from device_list
        connect by level < 3
        ;
 begin
    for r in simu_in_data loop 
    
        pkg_tcp_svr.incoming_data(r.device_id, r.data_type, r.data_str
                                 ,r.ip_addr, r.ip_port, v_out_msg); 
		dbms_output.put_line(v_out_msg);						 

    end  loop;
end;
/
set echo on
